package com.yidu.StockControl.mapper;

import com.yidu.StockControl.entity.SecurityInventors;
import com.yidu.StockControl.entity.SecurityInventory;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 *证券应收应付库存  证券应收应付库存    证券应收应付库存
 */
@Repository
public interface SecurityInventoryMapper {
    @Select("select * from securityInventory WHERE 1=1 ${strWhere} LIMIT #{page},#{limit}")
    public List<SecurityInventory> selectSecurityInventory(Map map);

    @Select("select count(*) from securityInventory")
    int selectSecurityInventoryCount();

    @Insert("insert into securityInventory values(#{securityInventoryId},#{fundId},#{securityId},"+
             "#{securityName},#{businessStatu},#{cashId},#{securityInventoryTime}," +
            "#{securityTotalAmount},#{securityType})")
    public int insertSecurityInventory(SecurityInventory securityInventory);
    @Update("update securityInventory set fundId =#{fundId}," +
            "securityId=#{securityId}," +
            "securityName=#{securityName},businessStatu=#{businessStatu},cashId=#{cashId}," +
            "securityInventoryTime=#{securityInventoryTime},securityTotalAmount=#{securityTotalAmount}," +
            "securityType=#{securityType} where securityInventoryId=#{securityInventoryId}")
    public void updateSecurityInventory(SecurityInventory securityInventory);
    @Delete("delete from securityInventory where securityInventoryId=#{securityInventoryId}")
    public void deleteSecurityInventory(String securityInventoryId);

    @Delete("delete from securityInventory where securityInventoryId=#{securityInventoryId} and fundId=#{fundId} and securityInventoryTime = DATE_FORMAT(DATE_ADD(STR_TO_DATE(#{dateTime},'%Y-%m-%d'),INTERVAL -1 DAY),'%Y-%m-%d')")
    public int deleteSecurityInventoryDate(String securityInventoryId, String fundId, String dateTime);

}

